﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="PwdPolicy.aspx.vb" Inherits="Map.PwdPolicy" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>密码策略设置</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <link rel="stylesheet" type="text/css" href="/_common/styles/global.css">    
	<LINK href="/_forms/styles/form.css" type="text/css" rel="stylesheet">
	<script language="javascript" src="/_common/scripts/global.js"></script>
	<script language="javascript" src="/_controls/settings.aspx"></script>
	<script language="javascript" src="/_controls/util/util.js"></script>
	<script language="javascript" src="/_controls/number/number.js"></script>	
    <style type="text/css">
        TD.section{ border :solid 1px #889dc2; }
        INPUT .checkbox {height:12px;border:0px;cursor:hand;}
        INPUT.radio{border:0px;cursor:hand;}
	    .section table{ margin-left :20px;table-layout :fixed; width:800px;border:0px;}        
        .sectionTitle
        {
        	width:				100%;
	        color:				#606050;
	        font-weight:		bold;
	        padding-left:		0px;
	        padding-bottom:		2px;
	    }
    </style>
    <script type="text/javascript">
        //处理控件的只读\编辑状态
        window.onload = function() {
                setPolicy("Complex", form1.chkComplexPolicy);
                setPolicy("Expiration", form1.chkExpirationPolicy);
                setPolicy("Lock", form1.chkLockPolicy);        
        }
        
        //勾选复选框处理子项
        function setPolicy(strPolicyName, me) {
            switch (strPolicyName.toUpperCase())
            {
                case "Complex".toUpperCase():
                    form1.txtMinLength.setReadOnly(!me.checked);
                    form1.rbComplex0.disabled = !me.checked;
                    form1.rbComplex1.disabled = !me.checked;
                    form1.rbComplex2.disabled = !me.checked;
                    break;
                case "Expiration".toUpperCase():
                    form1.txtExpirationDays.setReadOnly(!me.checked);
                    form1.txtAlramDays.setReadOnly(!me.checked);
                    form1.chkPwdChanged.disabled = !me.checked;
                    break;
                case "Lock".toUpperCase():
                    form1.txtWrongTimes.setReadOnly(!me.checked);
                    break;
                default:
                    break;   
            }
        }

        //校验录入值
        function checkInput(strPolicyName, me) {
            switch (strPolicyName.toUpperCase()) {
                case "Complex".toUpperCase():
                    if (me.checked && form1.txtMinLength.value == "") {
                        alert("请录入最小长度值！");
                        form1.txtMinLength.focus();
                        return false;
                    }
                    break;
                case "Expiration".toUpperCase():
                    if (me.checked && form1.txtExpirationDays.value == "") {
                        alert("请录入有效天数！");
                        form1.txtExpirationDays.focus();
                        return false;
                    }
                    if (me.checked && form1.txtAlramDays.value == "") {
                        alert("请录入过期前提醒天数！");
                        form1.txtAlramDays.focus();
                        return false;
                    }
                    if (me.checked && parseInt(form1.txtAlramDays.value) > parseInt(form1.txtExpirationDays.value)) {
                        alert("提醒天数不能超过有效天数！");
                        form1.txtAlramDays.focus();
                        form1.txtAlramDays.select();
                        return false;
                    }
                    break;
                case "Lock".toUpperCase():
                    if (me.checked && form1.txtWrongTimes.value == "") {
                        alert("请录入最大错误次数！");
                        form1.txtWrongTimes.focus();
                        return false;
                    }
                    break;
                default:
                    break;
            }
            return true;
        }

        //保存前校验
        function beforeSave() {
            if (!checkInput("Complex", form1.chkComplexPolicy)) {
                event.returnValue = false;
                return;
            }
            if (!checkInput("Expiration", form1.chkExpirationPolicy)) {
                event.returnValue = false;
                return;
            }
            if (!checkInput("Lock", form1.chkLockPolicy)) {
                event.returnValue = false;
                return;
            }
            //提示保存
            if (!confirm("确实要保存当前的密码策略设置吗？")) {
                event.returnValue = false;
                return;                
            }
            //回填值
            if (form1.rbComplex0.checked) form1.hfComplex.value = 0;
            else if (form1.rbComplex1.checked) form1.hfComplex.value = 1;
            else if (form1.rbComplex2.checked) form1.hfComplex.value = 2;
            else form1.hfComplex.value = 0;
            if (form1.chkPwdChanged.checked) form1.hfPwdChanged.value = 1;
            else form1.hfPwdChanged.value = 0;
        }
        
        
    </script>
</head>
<body MS_POSITIONING="GridLayout" class="tab" style="PADDING-RIGHT:10px;PADDING-LEFT:10px;PADDING-BOTTOM:10px;PADDING-TOP:10px;">
    <form id="form1" runat="server">
    <asp:HiddenField ID="hfComplex" runat="server" />
    <asp:HiddenField ID="hfPwdChanged" runat="server" />
    <div>
        <table border="0" width="100%">
        <tr height="12px"><td><span class="sectionTitle">密码复杂性</span></td></tr>
        <tr><td class="section">
                <asp:CheckBox ID="chkComplexPolicy" runat="server" Text="启用" OnClick="setPolicy('Complex',this)"  /> 
                <table>
                    <tr>
                        <td>最小长度&nbsp;<asp:TextBox ID="txtMinLength" runat="server" Width="50px" CssClass="num" min="1" max="50" dt="int" acc="0"></asp:TextBox>字符</td>
                    </tr>
                    <tr>
                        <td>密码内容必须包括：<br/>
                            &nbsp;&nbsp;&nbsp;<asp:RadioButton ID="rbComplex0" GroupName="grpComplex" runat="server" Text="数字、字母" /><br/>
                            &nbsp;&nbsp;&nbsp;<asp:RadioButton ID="rbComplex1" GroupName="grpComplex" runat="server" Text="数字、大写字母、小写字母"/><br/>
                            &nbsp;&nbsp;&nbsp;<asp:RadioButton ID="rbComplex2" GroupName="grpComplex" runat="server" Text="数字、大写字母、小写字母、特殊字符（如：!、@、#、$）" />
                        </td>
                    </tr>
                </table>
        </td></tr>
        <tr height="15px"><!--间隔--></tr>
        <tr height="12px"><td><span class="sectionTitle">密码有效期</span></td></tr>
        <tr><td class="section">
                <asp:CheckBox ID="chkExpirationPolicy" runat="server" Text="启用" OnClick="setPolicy('Expiration',this)" />
                <table>
                    <tr>
                        <td>有效天数&nbsp;&nbsp;&nbsp;<asp:TextBox ID="txtExpirationDays" runat="server" Width ="30px" CssClass="num" min="1" max="999" dt="int" acc="0"></asp:TextBox>天</td>
                    </tr>
                    <tr>
                        <td>密码过期前&nbsp;<asp:TextBox ID="txtAlramDays" runat="server" Width ="30px" CssClass="num" min="1" max="999" dt="int" acc="0"></asp:TextBox>天登录时提醒更改密码</td>
                    </tr>
                    <tr>
                        <td><asp:CheckBox ID="chkPwdChanged" runat="server" Text="修改密码不能与前一次密码相同" /></td>
                    </tr>
                </table>
                <br />
              <span><asp:CheckBox ID="chkFirstLogin" runat="server" Text="首次登录时用户必须更改密码" /></span>
        </td></tr>
        <tr height="15px"><!--间隔--></tr>
        <tr height="12px"><td><span class="sectionTitle">帐户锁定</span></td></tr>
        <tr><td class="section">
                <asp:CheckBox ID="chkLockPolicy" runat="server" Text="启用"  OnClick="setPolicy('Lock',this)"/>
                <table>
                    <tr>
                        <td>密码连续&nbsp;<asp:TextBox ID="txtWrongTimes" runat="server" CssClass="num" Width ="30px" min="1" max="999" dt="int" acc="0"></asp:TextBox>次错误会锁定该帐户</td>
                    </tr>
                </table>
        </td></tr>
        <tr height="15px"><!--间隔--></tr>
        <tr><td style="text-align :right;">
        <asp:Button ID="btnSave" runat="server" Text="保存" OnClientClick="beforeSave()"  />
        </td></tr>
     </table> 
    </form>
</body>
</html>
